// 引入windi css
import '@/plugins/windi.css'

// 导入全局的svg图标
import '@/plugins/svgIcon'

// 初始化多语言
import { setupI18n } from '@/plugins/vueI18n'

// 引入状态管理
import { setupStore } from '@/store'

// 全局组件
import { setupGlobCom } from '@/components'

// 引入element-plus
import { setupElementPlus } from '@/plugins/elementPlus'

// 引入全局样式
import '@/styles/index.less'

// 引入动画
import '@/plugins/animate.css'

// 路由
import { setupRouter } from './router'

// 权限
import setupDirectives from './directives'

import { createApp } from 'vue'

import App from './App.vue'

import './permission'

import { setupGlobRevModules } from './modules'

import { setupVxeTable } from './utils/vxeTable'

import { setupVMdEditor } from './utils/vMdEditor'

import { setupDataView } from './utils/dataView'

import { setupUI } from './utils/initUI'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import * as svg from '@element-plus/icons-vue'

import SvgIcon from '@/components/svgIcon/index.vue'

export function elSvg(app: any) {
  const icons = svg as any
  for (const i in icons) {
    app.component(`ele-${icons[i].name}`, icons[i])
  }
  app.component('SvgIcon', SvgIcon)
}

// 创建实例
const setupAll = async () => {
  const app = createApp(App)

  await setupI18n(app)

  setupStore(app)

  setupGlobCom(app)

  setupElementPlus(app)

  setupRouter(app)

  setupDirectives(app)

  setupGlobRevModules(app)

  setupVxeTable(app)

  setupVMdEditor(app)

  setupDataView(app)

  setupUI()

  app.use(ElementPlus)

  // app.component('SvgIcon', SvgIcon);
  elSvg(app)

  app.mount('#app')
}

setupAll()
